clear
rng default
load IdSetW

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% Projections in one dimension %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ntypes_w=3;
V_1=cell(ntypes_w,1);
V_2=cell(ntypes_w,1);
V_3=cell(ntypes_w,1);
for y=1:ntypes_w
    V_1{y}=[min(IdSetW{y}(:,2)); max(IdSetW{y}(:,2))];
    V_2{y}=[min(IdSetW{y}(:,3)); max(IdSetW{y}(:,3))];
    V_3{y}=[min(IdSetW{y}(:,4)); max(IdSetW{y}(:,4))];
end

save('V_intervals.mat', 'V_1', 'V_2', 'V_3')


clearvars -except IdSetW ntypes_w


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% Projections in two dimensions %%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
load V_CS
for y=1:ntypes_w
    %v2y v3y
    M=unique([IdSetW{y}(:,3) IdSetW{y}(:,4)], 'rows', 'stable'); 
    figure
    scatter(M(:,1), M(:,2), 60,'k', 'filled')
    hold on
    scatter(V_CS(2,y), V_CS(3,y), 60,'r', 'filled')
    xlabel(sprintf('V_{2%d}',y),'FontSize', 25) 
    ylabel(sprintf('V_{3%d}',y),'FontSize', 25)
    xlim([-20 20])
    ylim([-20 20])
    box on
    set(gca, 'ytick',-20:10:20,'xtick',-20:10:20,'FontSize',20)
    saveas(gcf,sprintf('V_2%d_3%d.jpg',y,y))
    

end


%close all





